import { DefaultFooter, getMenuData, getPageTitle } from '@ant-design/pro-layout';
import { Helmet, HelmetProvider } from 'react-helmet-async';
import { Link, SelectLang, useIntl, connect, FormattedMessage } from 'umi';
import { GithubOutlined } from '@ant-design/icons';
import React from 'react';
import logo from '../assets/logo.svg';
import styles from './UserLayout.less';

const UserLayout = (props) => {
  const {
    route = {
      routes: [],
    },
  } = props;
  const { routes = [] } = route;
  const {
    children,
    location = {
      pathname: '',
    },
  } = props;
  const { formatMessage } = useIntl();
  const { breadcrumb } = getMenuData(routes);
  const title = getPageTitle({
    pathname: location.pathname,
    formatMessage,
    breadcrumb,
    ...props,
  });
  return (
    <HelmetProvider>
      <Helmet>
        <title>{title}</title>
        <meta name="description" content={title} />
      </Helmet>

      <div className={styles.container}>
        <div className={styles.lang}>
          <SelectLang />
        </div>
        <div className={styles.content}>
          <div className={styles.top}>
            <div className={styles.header}>
              <Link to="/">
                <img alt="logo" className={styles.logo} src={logo} />
                <span className={styles.title}>高职院校教学质量评价系统</span>
              </Link>
            </div>
            <div className={styles.desc}>
              <FormattedMessage
                id="pages.layouts.userLayout.title"
                defaultMessage="一款高质量的在线评教平台 - (交院出品必属精品)"
              />
            </div>
          </div>
          {children}
        </div>
        <DefaultFooter
    copyright={`${new Date().getFullYear()} 河北交通职业技术学院出品`}
    links={[
      {
        key: '河北交通职业技术学院 - 官网',
        title: '河北交通职业技术学院 - 官网',
        href: 'https://www.hebjtxy.cn/',
        blankTarget: true,
      },
      {
        key: 'github',
        title: <GithubOutlined />,
        href: 'https://gitee.com/LJ_PGSY/quality-evaluation-system',
        blankTarget: true,
      },
      {
        key: '河北交通职业技术学院 - 百度百科',
        title: '河北交通职业技术学院 - 百度百科',
        href: 'https://baike.baidu.com/item/%E6%B2%B3%E5%8C%97%E4%BA%A4%E9%80%9A%E8%81%8C%E4%B8%9A%E6%8A%80%E6%9C%AF%E5%AD%A6%E9%99%A2/10116921?fr=aladdin',
        blankTarget: true,
      },
    ]}
  />
      </div>
    </HelmetProvider>
  );
};

export default connect(({ settings }) => ({ ...settings }))(UserLayout);
